import Vue from 'vue'
import MessageComponent from './tpl'

let instance

let MessageConstructor = Vue.extend(MessageComponent)

let initInstance = () => {
  instance = new MessageConstructor({
    el: document.createElement('div')
  })
  document.body.appendChild(instance.$el)
}

let Message = () => {
  initInstance()
  return {
    loading: instance.loading,
    success: instance.success,
    error: instance.error,
    close: instance.close
  }
}
export default {
  install (Vue) {
    Vue.prototype.$Message= Message()
  }
}
